package controller;

import java.sql.Date;
import java.util.ArrayList;

import org.apache.log4j.Logger;

import com.opensymphony.xwork2.ActionSupport;

import dao.BookTourDAO;
import entity.BookTour;

public class BookTourAction extends ActionSupport {
    private int visitorID;
    private int tourID;
    private short quantity;
    private ArrayList<BookTour> listBookTours;
    private static final Logger logger = Logger.getLogger(BookTourAction.class);
    
    @Override
    public String execute() throws Exception {    	
        try {
    		Date date = new Date(System.currentTimeMillis());  		
    		
        	if (BookTourDAO.bookTour(visitorID, tourID, quantity, date)) {
        		logger.warn("Book Tour successfully");
        	    return SUCCESS;	
        	}
        } catch (Exception ex) {
        	
        }
        logger.error("Book tour failed");
        return ERROR;
    }
    
    public String display() {
    	listBookTours = BookTourDAO.getListBookTour();
    	return SUCCESS;
    }
    
	public int getVisitorID() {
		return visitorID;
	}

	public void setVisitorID(int visitorID) {
		this.visitorID = visitorID;
	}

	public int getTourID() {
		return tourID;
	}

	public void setTourID(int tourID) {
		this.tourID = tourID;
	}

	public short getQuantity() {
		return quantity;
	}

	public void setQuantity(short quantity) {
		this.quantity = quantity;
	}

	public ArrayList<BookTour> getListBookTours() {
		return listBookTours;
	}

	public void setListBookTours(ArrayList<BookTour> listBookTours) {
		this.listBookTours = listBookTours;
	}
}
